package com.chapter14.demo2;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

/**
 * 筛选和截断
 */
public class PartialStream {
    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(1,3,5,7,9,11,13,5,7,9);
        //获取大于7的元素
        Stream<Integer> stream = list.stream();
        stream.filter(x->x>7).forEach(x-> System.out.printf("%d ",x));


        //去重
        stream = list.stream();
        System.out.println();
        stream.distinct().forEach(x-> System.out.printf("%d ",x));
    }
}
